/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.vtcc.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.vtcc.model.StrainEntry;
import vn.com.fis.portal.vtcc.model.StrainEntryModel;
import vn.com.fis.portal.vtcc.model.StrainEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the StrainEntry service. Represents a row in the &quot;vtcc_strain&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.vtcc.model.StrainEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link StrainEntryImpl}.
 * </p>
 *
 * @author loind
 * @see StrainEntryImpl
 * @see vn.com.fis.portal.vtcc.model.StrainEntry
 * @see vn.com.fis.portal.vtcc.model.StrainEntryModel
 * @generated
 */
@JSON(strict = true)
public class StrainEntryModelImpl extends BaseModelImpl<StrainEntry>
	implements StrainEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a strain entry model instance should use the {@link vn.com.fis.portal.vtcc.model.StrainEntry} interface instead.
	 */
	public static final String TABLE_NAME = "vtcc_strain";
	public static final Object[][] TABLE_COLUMNS = {
			{ "strainId", Types.BIGINT },
			{ "strainName", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "status", Types.INTEGER },
			{ "sampleId", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table vtcc_strain (strainId LONG not null primary key,strainName VARCHAR(75) null,description VARCHAR(75) null,status INTEGER,sampleId INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table vtcc_strain";
	public static final String ORDER_BY_JPQL = " ORDER BY strainEntry.strainName ASC";
	public static final String ORDER_BY_SQL = " ORDER BY vtcc_strain.strainName ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.vtcc.model.StrainEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.vtcc.model.StrainEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static StrainEntry toModel(StrainEntrySoap soapModel) {
		StrainEntry model = new StrainEntryImpl();

		model.setStrainId(soapModel.getStrainId());
		model.setStrainName(soapModel.getStrainName());
		model.setDescription(soapModel.getDescription());
		model.setStatus(soapModel.getStatus());
		model.setSampleId(soapModel.getSampleId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<StrainEntry> toModels(StrainEntrySoap[] soapModels) {
		List<StrainEntry> models = new ArrayList<StrainEntry>(soapModels.length);

		for (StrainEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.vtcc.model.StrainEntry"));

	public StrainEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _strainId;
	}

	public void setPrimaryKey(long primaryKey) {
		setStrainId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_strainId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return StrainEntry.class;
	}

	public String getModelClassName() {
		return StrainEntry.class.getName();
	}

	@JSON
	public long getStrainId() {
		return _strainId;
	}

	public void setStrainId(long strainId) {
		_strainId = strainId;
	}

	@JSON
	public String getStrainName() {
		if (_strainName == null) {
			return StringPool.BLANK;
		}
		else {
			return _strainName;
		}
	}

	public void setStrainName(String strainName) {
		_strainName = strainName;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_status = status;
	}

	@JSON
	public int getSampleId() {
		return _sampleId;
	}

	public void setSampleId(int sampleId) {
		_sampleId = sampleId;
	}

	@Override
	public StrainEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (StrainEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					StrainEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		StrainEntryImpl strainEntryImpl = new StrainEntryImpl();

		strainEntryImpl.setStrainId(getStrainId());
		strainEntryImpl.setStrainName(getStrainName());
		strainEntryImpl.setDescription(getDescription());
		strainEntryImpl.setStatus(getStatus());
		strainEntryImpl.setSampleId(getSampleId());

		strainEntryImpl.resetOriginalValues();

		return strainEntryImpl;
	}

	public int compareTo(StrainEntry strainEntry) {
		int value = 0;

		value = getStrainName().compareTo(strainEntry.getStrainName());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		StrainEntry strainEntry = null;

		try {
			strainEntry = (StrainEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = strainEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<StrainEntry> toCacheModel() {
		StrainEntryCacheModel strainEntryCacheModel = new StrainEntryCacheModel();

		strainEntryCacheModel.strainId = getStrainId();

		strainEntryCacheModel.strainName = getStrainName();

		String strainName = strainEntryCacheModel.strainName;

		if ((strainName != null) && (strainName.length() == 0)) {
			strainEntryCacheModel.strainName = null;
		}

		strainEntryCacheModel.description = getDescription();

		String description = strainEntryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			strainEntryCacheModel.description = null;
		}

		strainEntryCacheModel.status = getStatus();

		strainEntryCacheModel.sampleId = getSampleId();

		return strainEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{strainId=");
		sb.append(getStrainId());
		sb.append(", strainName=");
		sb.append(getStrainName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append(", sampleId=");
		sb.append(getSampleId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.vtcc.model.StrainEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>strainId</column-name><column-value><![CDATA[");
		sb.append(getStrainId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>strainName</column-name><column-value><![CDATA[");
		sb.append(getStrainName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sampleId</column-name><column-value><![CDATA[");
		sb.append(getSampleId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = StrainEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			StrainEntry.class
		};
	private long _strainId;
	private String _strainName;
	private String _description;
	private int _status;
	private int _sampleId;
	private transient ExpandoBridge _expandoBridge;
	private StrainEntry _escapedModelProxy;
}